package controllers;

import java.util.ArrayList;
import java.util.List;

import models.Menu;

public class MenuWrapper {
	public Menu menu;
	public List<MenuWrapper> children = new ArrayList<MenuWrapper>();
	
	public MenuWrapper(Menu m) {
		menu = m;
	}
	
	public static boolean insertMenu(MenuWrapper root, MenuWrapper m) {
		if (root.menu.getId() == m.menu.getPid()) {
			root.children.add(m);
			return true;
		} else {
			for(MenuWrapper w: root.children) {
				insertMenu(w, m);
			}
		}
		return false;
	}
}
